package com.example.zhangwei.adapter;

import java.util.ArrayList;

import com.example.zhangwei.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class RefreshAdapter extends BaseAdapter{
	
	private Context mContext;
	
	private ArrayList<String> mDataList;
	
	public RefreshAdapter(Context context, ArrayList<String> list)
	{
		mContext = context;
        mDataList = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mDataList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mDataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewHolder;
        if (convertView == null)
        {
        	viewHolder = new ViewHolder();
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.expand_list_items, null);
            viewHolder.imageView = (ImageView) convertView.findViewById(R.id.expand_list_image);
            viewHolder.name = (TextView) convertView.findViewById(R.id.expand_list_text);;
            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.imageView.setVisibility(View.INVISIBLE);
        viewHolder.name.setText(mDataList.get(position).toString());
        viewHolder.name.setTextColor(Color.WHITE);
		return convertView;
	}
	
	private class ViewHolder
    {
        TextView name;
        ImageView imageView;
    }

}
